import 'package:flutter/material.dart';
import 'reason.dart';

class Card2Page extends StatefulWidget {
  Card2Page({Key key, this.title,this.para}) : super(key: key);
  final String title;
  final Map<String,dynamic> para;
  @override
  _Card2Page createState() => _Card2Page();
}

class _Card2Page extends State<Card2Page> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }
  var name = "";
  var cardid = "";
  int cardType = 0;
  @override
  Widget build(BuildContext context) {
    name = this.widget.para["visitor_name"];
    cardid = this.widget.para["id_no"];
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Padding(padding: EdgeInsets.all(20),child: Column(
        children: <Widget>[
          // Text("請輸入證件資料"),
          // SizedBox(
          //   height: 20,
          // ),
          Row(children: <Widget>[
            Text("姓名:",style: TextStyle(fontWeight: FontWeight.bold),),
            Expanded(child: TextField(onChanged: (str){
              this.name = str;
            },),),
          ],),
          Row(children: <Widget>[
            Text("證件號碼:",style: TextStyle(fontWeight: FontWeight.bold)),
            Expanded(child: TextField(onChanged: (str){
              this.cardid = str;
            },),),
          ],),
          Row(
            children: <Widget>[
              Text("證件類別",style: TextStyle(fontWeight: FontWeight.bold)),
              SizedBox(
                width: 30,
              ),
              Radio(
                  value: 0,
                  groupValue: this.cardType,
                  onChanged: (str) {
                    setState(() {
                      cardType = 0;
                    });
                  }),
              Text("香港身份證",style: TextStyle(fontWeight: FontWeight.bold)),
              SizedBox(
                width: 30,
              ),
              Radio(
                  value: 1,
                  groupValue: this.cardType,
                  onChanged: (str) {
                    setState(() {
                      cardType = 1;
                    });
                  }),
              Text("駕駛證",style: TextStyle(fontWeight: FontWeight.bold)),
              SizedBox(
                width: 30,
              ),
              Radio(
                  value: 2,
                  groupValue: this.cardType,
                  onChanged: (str) {
                    setState(() {
                      cardType = 2;
                    });
                  }),
              Text("有效之工作證明 / 證件",style: TextStyle(fontWeight: FontWeight.bold)),
              SizedBox(
                width: 30,
              ),
            ],
          ),
          SizedBox(
            height: 20,
          ),
          Row(children: <Widget>[
            Align(alignment: Alignment.centerLeft,child: MaterialButton(
              materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
              height: 40,
              minWidth: 100,
              padding: EdgeInsets.all(0),
              color: Color(0xff4a701e),
              textColor: Colors.white,
              shape: RoundedRectangleBorder(
                  borderRadius:
                  BorderRadius.all(Radius.circular(20))),
              onPressed: () {
                Navigator.of(context).pop();
              },
              child: Text("上一步"),
            ),)
            ,Align(alignment: Alignment.centerLeft,child: MaterialButton(
              materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
              height: 40,
              minWidth: 100,
              padding: EdgeInsets.all(0),
              color: Color(0xff4a701e),
              textColor: Colors.white,
              shape: RoundedRectangleBorder(
                  borderRadius:
                  BorderRadius.all(Radius.circular(20))),
              onPressed: () {
                print(this.name);
                print(this.cardid);
                print(this.cardType);
//                Navigator.of(context).pushNamed("reason");
                var dic = this.widget.para;
                dic["id_no"] = this.cardid;
                dic["id_type"] = this.cardType+1;
                dic["gender"] = 1;
                dic["visitor_name"] = this.name;
                Navigator.push( context, MaterialPageRoute(builder: (context) => ReasonPage(title: "",para: dic)),);

              },
              child: Text("下一步"),
            ),),
          ],),
        ],
      ),),
    );
  }
}